//
//  RENavigationViewController.m
//  录音
//
//  Created by ywy on 2016/12/22.
//  Copyright © 2016年 Wely. All rights reserved.
//

#import "RENavigationViewController.h"
#import "UIView+YPExtension.h"
#import "RETabBarViewController.h"
#import "FirstViewController.h"

@interface RENavigationViewController ()

@end

@implementation RENavigationViewController

+ (void)initialize {
    
    // 设置导航栏背景
    UINavigationBar *navBar = [UINavigationBar appearance];
    [navBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:RERGBColor(255, 105, 96),NSForegroundColorAttributeName,nil]];
}


- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    if (self.childViewControllers.count > 0) {
////        [viewController.navigationController.navigationBar setShadowImage:[UIImage new]];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        button.size = CGSizeMake(40, 30);
//        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
//        button.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
        [button addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
//        // 修改导航栏左边item
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
//        viewController.hidesBottomBarWhenPushed = YES;
    }
    
//    RETabBarViewController * reTabBar = (RETabBarViewController*)self.tabBarController;
////    [reTabBar HideTabarView:YES];
//    reTabBar.tabBar.hidden  = YES;
//    reTabBar.bottomView.alpha = 0;
    
    [super pushViewController:viewController animated:animated];
}


- (void)backAction {
    
//    RETabBarViewController * reTabBar = (RETabBarViewController*)self.tabBarController;
//    reTabBar.tabBar.hidden = YES;
//    reTabBar.bottomView.alpha = 1;
    [self popViewControllerAnimated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.interactivePopGestureRecognizer.delegate = nil;
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
